{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from config import ChromaConfig\n",
    "from data_loader import DataLoader\n",
    "from chroma_manager import ChromaManager"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 初始化配置\n",
    "config = ChromaConfig(\n",
    "    host=\"localhost\",  # 使用本地ChromaDB\n",
    "    ollama_base_url=\"http://localhost:11434\",\n",
    "    embedding_model=\"viosay/conan-embedding-v1\"\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>指标代码</th>\n",
       "      <th>指标名称</th>\n",
       "      <th>主题描述</th>\n",
       "      <th>自定义计算表达式</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>S0010004</td>\n",
       "      <td>全院总收入(核算日期)</td>\n",
       "      <td>收入主题</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>S0010005</td>\n",
       "      <td>住院总收入(计费日期)</td>\n",
       "      <td>收入主题</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>S0010006</td>\n",
       "      <td>住院总收入(结算日期)</td>\n",
       "      <td>收入主题</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>S0010007</td>\n",
       "      <td>住院总收入(交账日期)</td>\n",
       "      <td>收入主题</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>S0010008</td>\n",
       "      <td>住院总收入(核算日期)</td>\n",
       "      <td>收入主题</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4865</th>\n",
       "      <td>C2000006</td>\n",
       "      <td>危急值检查平均处理时长</td>\n",
       "      <td>NaN</td>\n",
       "      <td>{S2000006/S2000004}</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4866</th>\n",
       "      <td>SJ2010043</td>\n",
       "      <td>医院临床营养师人员数(三级评审)</td>\n",
       "      <td>绩效填报主题</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4867</th>\n",
       "      <td>SJ2010044</td>\n",
       "      <td>药学专业技术人员数(三级评审)</td>\n",
       "      <td>绩效填报主题</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4868</th>\n",
       "      <td>SJ2010045</td>\n",
       "      <td>科研项目立项经费总金额(三级评审)</td>\n",
       "      <td>绩效填报主题</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4869</th>\n",
       "      <td>CJ2010031</td>\n",
       "      <td>每百名卫生技术人员科研项目经费(三级评审)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>{SJ2010045/SJ2010003}</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4870 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           指标代码                   指标名称    主题描述               自定义计算表达式\n",
       "0      S0010004            全院总收入(核算日期)    收入主题                    NaN\n",
       "1      S0010005            住院总收入(计费日期)    收入主题                    NaN\n",
       "2      S0010006            住院总收入(结算日期)    收入主题                    NaN\n",
       "3      S0010007            住院总收入(交账日期)    收入主题                    NaN\n",
       "4      S0010008            住院总收入(核算日期)    收入主题                    NaN\n",
       "...         ...                    ...     ...                    ...\n",
       "4865   C2000006            危急值检查平均处理时长     NaN    {S2000006/S2000004}\n",
       "4866  SJ2010043       医院临床营养师人员数(三级评审)  绩效填报主题                    NaN\n",
       "4867  SJ2010044        药学专业技术人员数(三级评审)  绩效填报主题                    NaN\n",
       "4868  SJ2010045      科研项目立项经费总金额(三级评审)  绩效填报主题                    NaN\n",
       "4869  CJ2010031  每百名卫生技术人员科研项目经费(三级评审)     NaN  {SJ2010045/SJ2010003}\n",
       "\n",
       "[4870 rows x 4 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "loader = DataLoader()\n",
    "indicators_df = loader.load_indicators()\n",
    "indicators_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>维度代码</th>\n",
       "      <th>维度描述</th>\n",
       "      <th>主题描述</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ASDate</td>\n",
       "      <td>出诊日期</td>\n",
       "      <td>资源主题</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Doc</td>\n",
       "      <td>医生信息</td>\n",
       "      <td>资源主题</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Dep</td>\n",
       "      <td>科室信息</td>\n",
       "      <td>资源主题</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>RegSess</td>\n",
       "      <td>出诊级别</td>\n",
       "      <td>资源主题</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>TimeRange</td>\n",
       "      <td>时段</td>\n",
       "      <td>资源主题</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1463</th>\n",
       "      <td>HospCode</td>\n",
       "      <td>医院信息</td>\n",
       "      <td>电子病历质控明细主题</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1464</th>\n",
       "      <td>AdmNo</td>\n",
       "      <td>就诊信息</td>\n",
       "      <td>电子病历质控明细主题</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1465</th>\n",
       "      <td>PapmiNo</td>\n",
       "      <td>患者主键</td>\n",
       "      <td>电子病历质控明细主题</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1466</th>\n",
       "      <td>TriggerDate</td>\n",
       "      <td>触发日期</td>\n",
       "      <td>电子病历质控明细主题</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1467</th>\n",
       "      <td>StatisticDate</td>\n",
       "      <td>日期</td>\n",
       "      <td>感染指标主题</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1468 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               维度代码  维度描述        主题描述\n",
       "0            ASDate  出诊日期        资源主题\n",
       "1               Doc  医生信息        资源主题\n",
       "2               Dep  科室信息        资源主题\n",
       "3           RegSess  出诊级别        资源主题\n",
       "4         TimeRange    时段        资源主题\n",
       "...             ...   ...         ...\n",
       "1463       HospCode  医院信息  电子病历质控明细主题\n",
       "1464          AdmNo  就诊信息  电子病历质控明细主题\n",
       "1465        PapmiNo  患者主键  电子病历质控明细主题\n",
       "1466    TriggerDate  触发日期  电子病历质控明细主题\n",
       "1467  StatisticDate    日期      感染指标主题\n",
       "\n",
       "[1468 rows x 3 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dimensions_df = loader.load_dimensions()\n",
    "dimensions_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 查询指标\n",
    "chroma = ChromaManager(config)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>指标代码</th>\n",
       "      <th>指标名称</th>\n",
       "      <th>主题描述</th>\n",
       "      <th>自定义计算表达式</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>138</th>\n",
       "      <td>C0000057</td>\n",
       "      <td>住院医疗占比(计费日期)</td>\n",
       "      <td>NaN</td>\n",
       "      <td>{S0010066/S0010004}</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         指标代码          指标名称 主题描述             自定义计算表达式\n",
       "138  C0000057  住院医疗占比(计费日期)  NaN  {S0010066/S0010004}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "query_df = indicators_df.query(\"指标代码 == 'C0000057'\")\n",
    "query_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'query_df' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[6], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m chroma\u001b[38;5;241m.\u001b[39mstore_indicators(query_df)\n",
      "\u001b[1;31mNameError\u001b[0m: name 'query_df' is not defined"
     ]
    }
   ],
   "source": [
    "chroma.store_indicators(query_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Storing indicators:  51%|█████▏    | 2506/4870 [03:38<03:32, 11.15it/s]Error storing indicator HQMSZ00216: [WinError 10054] 远程主机强迫关闭了一个现有的连接。\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error storing indicator HQMSZ00216: [WinError 10054] 远程主机强迫关闭了一个现有的连接。\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Error storing indicator HQMSZ00217: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Storing indicators:  51%|█████▏    | 2508/4870 [03:40<12:13,  3.22it/s]Error storing indicator HQMSZ00219: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00220: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00221: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00222: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00223: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00224: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00225: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00228: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00231: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010210: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010211: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010212: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010213: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010214: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010215: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010216: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010217: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010218: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010219: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010220: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010221: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010222: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010223: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010224: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010225: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010226: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010227: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010228: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010229: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000465: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Storing indicators:  52%|█████▏    | 2538/4870 [03:40<01:43, 22.57it/s]Error storing indicator C0000466: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000467: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000468: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000469: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000470: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000471: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000472: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000473: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000474: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000475: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000476: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000477: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000478: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000479: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000480: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000481: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000482: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000483: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000484: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSX0265: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0020052: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0020053: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00239: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00240: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00241: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error storing indicator HQMSZ00217: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00219: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00220: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00221: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00222: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00223: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00224: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00225: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00228: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00231: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010210: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010211: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010212: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010213: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010214: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010215: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010216: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010217: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010218: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010219: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010220: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010221: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010222: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010223: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010224: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010225: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010226: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010227: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010228: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0010229: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000465: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000466: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000467: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000468: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000469: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000470: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000471: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000472: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000473: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000474: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000475: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000476: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000477: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000478: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000479: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000480: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000481: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000482: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000483: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator C0000484: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSX0265: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0020052: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator S0020053: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00239: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00240: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00241: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Error storing indicator HQMSZ00243: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00245: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSX0271: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSX0273: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSX0274: [WinError 10054] 远程主机强迫关闭了一个现有的连接。 in add.\n",
      "Error storing indicator HQMSX0275: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator SJ010009: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Storing indicators:  53%|█████▎    | 2570/4870 [03:40<00:48, 47.90it/s]Error storing indicator SJ010010: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ010001: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator SJ2010033: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator SJ2010034: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010001: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010002: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010003: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010004: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010005: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010006: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010007: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010008: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010009: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010010: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010011: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010012: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010013: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010014: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010015: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010016: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010017: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010018: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010019: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010020: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010021: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010022: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010023: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010024: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010025: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010026: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010027: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020001: [WinError 10054] 远程主机强迫关闭了一个现有的连接。 in add.\n",
      "Error storing indicator CJ2020002: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020003: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020004: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020005: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020006: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020007: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020008: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020009: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Storing indicators:  54%|█████▎    | 2610/4870 [03:40<00:26, 86.03it/s]Error storing indicator CJ2020010: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020011: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020012: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020013: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020014: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020015: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020016: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020017: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020018: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020019: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020020: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020021: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020022: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020023: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020024: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020025: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020026: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020027: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020028: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020029: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020030: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020031: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error storing indicator HQMSZ00243: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSZ00245: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSX0271: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSX0273: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator HQMSX0274: [WinError 10054] 远程主机强迫关闭了一个现有的连接。 in add.\n",
      "Error storing indicator HQMSX0275: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator SJ010009: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator SJ010010: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ010001: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator SJ2010033: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator SJ2010034: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010001: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010002: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010003: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010004: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010005: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010006: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010007: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010008: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010009: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010010: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010011: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010012: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010013: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010014: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010015: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010016: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010017: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010018: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010019: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010020: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010021: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010022: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010023: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010024: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010025: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010026: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2010027: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020001: [WinError 10054] 远程主机强迫关闭了一个现有的连接。 in add.\n",
      "Error storing indicator CJ2020002: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020003: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020004: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020005: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020006: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020007: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020008: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020009: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020010: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020011: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020012: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020013: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020014: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020015: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020016: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020017: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020018: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020019: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020020: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020021: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020022: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020023: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020024: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020025: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020026: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020027: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020028: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020029: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020030: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing indicator CJ2020031: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Storing indicators: 100%|██████████| 4870/4870 [07:32<00:00, 10.77it/s]\n"
     ]
    }
   ],
   "source": [
    "# chroma.store_indicators(indicators_df.loc[0:10])\n",
    "chroma.store_indicators(indicators_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "filtered_indicators = indicators_df[indicators_df['自定义计算表达式'].notna()]\n",
    "filtered_indicators"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# chroma.store_indicators(filtered_indicators)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Storing dimensions:  82%|████████▏ | 1210/1468 [01:38<00:22, 11.51it/s]Error storing dimension Dep: [WinError 10054] 远程主机强迫关闭了一个现有的连接。 in add.\n",
      "Storing dimensions:  83%|████████▎ | 1212/1468 [01:38<00:21, 11.73it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error storing dimension Dep: [WinError 10054] 远程主机强迫关闭了一个现有的连接。 in add.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Error storing dimension StatisticDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AcceptDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Storing dimensions:  83%|████████▎ | 1214/1468 [01:39<01:14,  3.42it/s]Error storing dimension AcceptGroupDr: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AdmType: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Age: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension BFCode: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension ContainerType: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension CorrectFlag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension RecDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension RecDep: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension RecHopCode: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension RecUserNo: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension StatisticDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Dep: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Doc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension HospCode: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension PatSex: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Urgent: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AdmDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AdmDepDr: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AdmDoc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension BFZFlag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension DisDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Dep: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Doc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension HospCode: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension InDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Storing dimensions:  84%|████████▍ | 1239/1468 [01:39<00:11, 20.18it/s]Error storing dimension InDept: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension InDoc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension OutDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension OutDept: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension OutDoc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension VarFlag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension ZXFlag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Doc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension OPAppDoc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension ApplyDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension applyurgentflag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension applyfrostflag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension SamplingDoc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Error storing dimension StatisticDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AcceptDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AcceptGroupDr: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AdmType: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Age: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension BFCode: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension ContainerType: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension CorrectFlag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension RecDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension RecDep: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension RecHopCode: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension RecUserNo: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension StatisticDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Dep: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Doc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension HospCode: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension PatSex: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Urgent: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AdmDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AdmDepDr: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension AdmDoc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension BFZFlag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension DisDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Dep: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Doc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension HospCode: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension InDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension InDept: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension InDoc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension OutDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension OutDept: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension OutDoc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension VarFlag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension ZXFlag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension Doc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension OPAppDoc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension ApplyDate: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension applyurgentflag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension applyfrostflag: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n",
      "Error storing dimension SamplingDoc: JSONDecodeError.__init__() missing 2 required positional arguments: 'doc' and 'pos'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Storing dimensions: 100%|██████████| 1468/1468 [01:58<00:00, 12.36it/s]\n"
     ]
    }
   ],
   "source": [
    "chroma.store_dimensions(dimensions_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'id': 'S0070002', 'text': '门诊就诊人次', 'metadata': {'code': 'S0070002', 'theme': '门诊就诊主题'}, 'distance': 119.44947814941406}, {'id': 'S0070201', 'text': '门诊就诊检查人次', 'metadata': {'code': 'S0070201', 'theme': '门诊就诊主题'}, 'distance': 125.88081359863281}, {'id': 'S0070240', 'text': '门诊下诊断人次', 'metadata': {'code': 'S0070240', 'theme': '门诊就诊主题'}, 'distance': 127.32969665527344}, {'id': 'S0020017', 'text': '门诊挂号人次', 'metadata': {'code': 'S0020017', 'theme': '挂号主题'}, 'distance': 129.12144470214844}, {'id': 'S0100003', 'text': '门诊诊断数量', 'metadata': {'code': 'S0100003', 'theme': '病人诊断主题'}, 'distance': 138.81631469726562}, {'id': 'S0150015', 'text': '门诊医保人次', 'metadata': {'code': 'S0150015', 'theme': '医保主题'}, 'distance': 139.03604125976562}, {'id': 'S0140006', 'text': '可挂号数量', 'metadata': {'code': 'S0140006', 'theme': '资源主题'}, 'distance': 141.2712860107422}, {'id': 'S0100001', 'text': '全院诊断数量', 'metadata': {'code': 'S0100001', 'theme': '病人诊断主题'}, 'distance': 144.92031860351562}, {'id': 'V0010015', 'text': '诊断操作人次', 'metadata': {'code': 'V0010015', 'theme': '重点手术报表'}, 'distance': 147.59051513671875}, {'id': 'S0020027', 'text': '门诊工作日挂号人次', 'metadata': {'code': 'S0020027', 'theme': '挂号主题'}, 'distance': 147.90150451660156}]\n"
     ]
    }
   ],
   "source": [
    "results = chroma.query_indicators(\"就诊量\", 10)\n",
    "print(results)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "results = chroma.query_dimensions(\"科室\")\n",
    "print(results)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "import chromadb\n",
    "client = chromadb.PersistentClient(path=\"./chroma_db\")\n",
    "collection = client.get_collection(name=\"dimensions\", embedding_function=chroma.embedding_function)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "collection.count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "collection.query(query_texts=\"收入\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'indicators': [{'id': 'S0010067',\n",
       "   'text': '住院医疗总收入(结算日期)',\n",
       "   'metadata': {'code': 'S0010067', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010005',\n",
       "   'text': '住院总收入(计费日期)',\n",
       "   'metadata': {'code': 'S0010005', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010069',\n",
       "   'text': '住院医疗总收入(核算日期)',\n",
       "   'metadata': {'code': 'S0010069', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010007',\n",
       "   'text': '住院总收入(交账日期)',\n",
       "   'metadata': {'code': 'S0010007', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010066',\n",
       "   'text': '住院医疗总收入(计费日期)',\n",
       "   'metadata': {'code': 'S0010066', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010004',\n",
       "   'text': '全院总收入(核算日期)',\n",
       "   'metadata': {'code': 'S0010004', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010068',\n",
       "   'text': '住院医疗总收入(交账日期)',\n",
       "   'metadata': {'code': 'S0010068', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010006',\n",
       "   'text': '住院总收入(结算日期)',\n",
       "   'metadata': {'code': 'S0010006', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010027',\n",
       "   'text': '住院药品总收入(结算日期)',\n",
       "   'metadata': {'code': 'S0010027', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010047',\n",
       "   'text': '住院材料总收入(结算日期)',\n",
       "   'metadata': {'code': 'S0010047', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010002',\n",
       "   'text': '全院总收入(结算日期)',\n",
       "   'metadata': {'code': 'S0010002', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010063',\n",
       "   'text': '全院医疗总收入(结算日期)',\n",
       "   'metadata': {'code': 'S0010063', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010028',\n",
       "   'text': '住院药品总收入(交账日期)',\n",
       "   'metadata': {'code': 'S0010028', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0150048',\n",
       "   'text': '住院基金支付总金额',\n",
       "   'metadata': {'code': 'S0150048', 'theme': '医保主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0150044',\n",
       "   'text': '住院医保总金额',\n",
       "   'metadata': {'code': 'S0150044', 'theme': '医保主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010029',\n",
       "   'text': '住院药品总收入(核算日期)',\n",
       "   'metadata': {'code': 'S0010029', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010008',\n",
       "   'text': '住院总收入(核算日期)',\n",
       "   'metadata': {'code': 'S0010008', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'C0000362',\n",
       "   'text': '住院医保药品总金额',\n",
       "   'metadata': {'code': 'C0000362', 'formula': '{S0150049+S0150050+S0150051}'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010026',\n",
       "   'text': '住院药品总收入(计费日期)',\n",
       "   'metadata': {'code': 'S0010026', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010049',\n",
       "   'text': '住院材料总收入(核算日期)',\n",
       "   'metadata': {'code': 'S0010049', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010079',\n",
       "   'text': '门诊医疗总收入(结算日期)',\n",
       "   'metadata': {'code': 'S0010079', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010019',\n",
       "   'text': '门诊总收入(结算日期)',\n",
       "   'metadata': {'code': 'S0010019', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010115',\n",
       "   'text': '住院中草药总收入(结算日期)',\n",
       "   'metadata': {'code': 'S0010115', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0150045',\n",
       "   'text': '住院医保内总金额',\n",
       "   'metadata': {'code': 'S0150045', 'theme': '医保主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0010095',\n",
       "   'text': '住院西药总收入(结算日期)',\n",
       "   'metadata': {'code': 'S0010095', 'theme': '收入主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'S0150046',\n",
       "   'text': '住院医保外总金额',\n",
       "   'metadata': {'code': 'S0150046', 'theme': '医保主题'},\n",
       "   'distance': 0},\n",
       "  {'id': 'C0000058',\n",
       "   'text': '住院医疗占比(结算日期)',\n",
       "   'metadata': {'code': 'C0000058', 'formula': '{S0010067/S0010005}'},\n",
       "   'distance': 85.44193267822266},\n",
       "  {'id': 'C0000060',\n",
       "   'text': '住院医疗占比(核算日期)',\n",
       "   'metadata': {'code': 'C0000060', 'formula': '{S0010069/S0010007}'},\n",
       "   'distance': 108.61600494384766},\n",
       "  {'id': 'C0000057',\n",
       "   'text': '住院医疗占比(计费日期)',\n",
       "   'metadata': {'code': 'C0000057', 'formula': '{S0010066/S0010004}'},\n",
       "   'distance': 108.98963928222656},\n",
       "  {'id': 'C0000059',\n",
       "   'text': '住院医疗占比(交账日期)',\n",
       "   'metadata': {'code': 'C0000059', 'formula': '{S0010068/S0010006}'},\n",
       "   'distance': 112.00505828857422},\n",
       "  {'id': 'C0000018',\n",
       "   'text': '住院药占比(结算日期)',\n",
       "   'metadata': {'code': 'C0000018', 'formula': '{S0010027/S0010005}'},\n",
       "   'distance': 118.73735046386719},\n",
       "  {'id': 'C0000038',\n",
       "   'text': '住院耗材占比(结算日期)',\n",
       "   'metadata': {'code': 'C0000038', 'formula': '{S0010047/S0010005}'},\n",
       "   'distance': 135.3946533203125},\n",
       "  {'id': 'C0000042',\n",
       "   'text': '全院医疗占比(结算日期)',\n",
       "   'metadata': {'code': 'C0000042', 'formula': '{S0010063/S0010002}'},\n",
       "   'distance': 140.68531799316406},\n",
       "  {'id': 'C0000019',\n",
       "   'text': '住院药占比(交账日期)',\n",
       "   'metadata': {'code': 'C0000019', 'formula': '{S0010028/S0010006}'},\n",
       "   'distance': 140.88381958007812},\n",
       "  {'id': 'C0000411',\n",
       "   'text': '住院医保基金支付占比',\n",
       "   'metadata': {'code': 'C0000411', 'formula': '{S0150048/S0150044}'},\n",
       "   'distance': 141.25875854492188},\n",
       "  {'id': 'C0000020',\n",
       "   'text': '住院药占比(核算日期)',\n",
       "   'metadata': {'code': 'C0000020', 'formula': '{S0010029/S0010008}'},\n",
       "   'distance': 144.33705139160156},\n",
       "  {'id': 'C0000369',\n",
       "   'text': '住院医保药占比',\n",
       "   'metadata': {'code': 'C0000369', 'formula': '{C0000362/S0150044}'},\n",
       "   'distance': 145.55911254882812},\n",
       "  {'id': 'C0000017',\n",
       "   'text': '住院药占比(计费日期)',\n",
       "   'metadata': {'code': 'C0000017', 'formula': '{S0010026/S0010004}'},\n",
       "   'distance': 147.42782592773438},\n",
       "  {'id': 'C0000040',\n",
       "   'text': '住院耗材占比(核算日期)',\n",
       "   'metadata': {'code': 'C0000040', 'formula': '{S0010049/S0010008}'},\n",
       "   'distance': 147.5328369140625},\n",
       "  {'id': 'C0000050',\n",
       "   'text': '门诊医疗占比(结算日期)',\n",
       "   'metadata': {'code': 'C0000050', 'formula': '{S0010079/S0010019}'},\n",
       "   'distance': 149.32688903808594},\n",
       "  {'id': 'C0000099',\n",
       "   'text': '住院中草药占比(结算日期)',\n",
       "   'metadata': {'code': 'C0000099', 'formula': '{S0010115/S0010027}'},\n",
       "   'distance': 149.42333984375},\n",
       "  {'id': 'C0000367',\n",
       "   'text': '住院医保内占比',\n",
       "   'metadata': {'code': 'C0000367', 'formula': '{S0150045/S0150044}'},\n",
       "   'distance': 150.43174743652344},\n",
       "  {'id': 'C0000037',\n",
       "   'text': '住院耗材占比(计费日期)',\n",
       "   'metadata': {'code': 'C0000037', 'formula': '{S0010047/S0010004}'},\n",
       "   'distance': 151.6373291015625},\n",
       "  {'id': 'C0000079',\n",
       "   'text': '住院西药占比(结算日期)',\n",
       "   'metadata': {'code': 'C0000079', 'formula': '{S0010095/S0010027}'},\n",
       "   'distance': 152.43751525878906},\n",
       "  {'id': 'C0000368',\n",
       "   'text': '住院医保外占比',\n",
       "   'metadata': {'code': 'C0000368', 'formula': '{S0150046/S0150044}'},\n",
       "   'distance': 153.69290161132812},\n",
       "  {'id': 'C0000039',\n",
       "   'text': '住院耗材占比(交账日期)',\n",
       "   'metadata': {'code': 'C0000039', 'formula': '{S0010049/S0010006}'},\n",
       "   'distance': 155.2711944580078}],\n",
       " 'themes': ['医保主题', '收入主题']}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results = chroma.query_indicators(\"按结算统计住院医疗占比\",20, True)\n",
    "results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "| 指标代码 | 指标描述 | 关联主题 | 计算公式 |\n",
      "|---|---|---|---|\n",
      "| S0010067 | 住院医疗总收入(结算日期) | 收入主题 | - |\n",
      "| S0010005 | 住院总收入(计费日期) | 收入主题 | - |\n",
      "| S0010069 | 住院医疗总收入(核算日期) | 收入主题 | - |\n",
      "| S0010007 | 住院总收入(交账日期) | 收入主题 | - |\n",
      "| S0010066 | 住院医疗总收入(计费日期) | 收入主题 | - |\n",
      "| S0010004 | 全院总收入(核算日期) | 收入主题 | - |\n",
      "| S0010068 | 住院医疗总收入(交账日期) | 收入主题 | - |\n",
      "| S0010006 | 住院总收入(结算日期) | 收入主题 | - |\n",
      "| S0010027 | 住院药品总收入(结算日期) | 收入主题 | - |\n",
      "| S0010047 | 住院材料总收入(结算日期) | 收入主题 | - |\n",
      "| S0010002 | 全院总收入(结算日期) | 收入主题 | - |\n",
      "| S0010063 | 全院医疗总收入(结算日期) | 收入主题 | - |\n",
      "| S0010028 | 住院药品总收入(交账日期) | 收入主题 | - |\n",
      "| S0150048 | 住院基金支付总金额 | 医保主题 | - |\n",
      "| S0150044 | 住院医保总金额 | 医保主题 | - |\n",
      "| S0010029 | 住院药品总收入(核算日期) | 收入主题 | - |\n",
      "| S0010008 | 住院总收入(核算日期) | 收入主题 | - |\n",
      "| C0000058 | 住院医疗占比(结算日期) | - | {S0010067/S0010005} |\n",
      "| C0000060 | 住院医疗占比(核算日期) | - | {S0010069/S0010007} |\n",
      "| C0000057 | 住院医疗占比(计费日期) | - | {S0010066/S0010004} |\n",
      "| C0000059 | 住院医疗占比(交账日期) | - | {S0010068/S0010006} |\n",
      "| C0000018 | 住院药占比(结算日期) | - | {S0010027/S0010005} |\n",
      "| C0000038 | 住院耗材占比(结算日期) | - | {S0010047/S0010005} |\n",
      "| C0000042 | 全院医疗占比(结算日期) | - | {S0010063/S0010002} |\n",
      "| C0000019 | 住院药占比(交账日期) | - | {S0010028/S0010006} |\n",
      "| C0000411 | 住院医保基金支付占比 | - | {S0150048/S0150044} |\n",
      "| C0000020 | 住院药占比(核算日期) | - | {S0010029/S0010008} |\n",
      "\n"
     ]
    }
   ],
   "source": [
    "result = chroma.get_indicators_table(\"按结算统计住院医疗占比\",10, True)\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'indicators': [{'id': 'S0010067', 'text': '住院医疗总收入(结算日期)', 'metadata': {'code': 'S0010067', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010005', 'text': '住院总收入(计费日期)', 'metadata': {'code': 'S0010005', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010007', 'text': '住院总收入(交账日期)', 'metadata': {'code': 'S0010007', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010069', 'text': '住院医疗总收入(核算日期)', 'metadata': {'code': 'S0010069', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010066', 'text': '住院医疗总收入(计费日期)', 'metadata': {'code': 'S0010066', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010004', 'text': '全院总收入(核算日期)', 'metadata': {'code': 'S0010004', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010068', 'text': '住院医疗总收入(交账日期)', 'metadata': {'code': 'S0010068', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010006', 'text': '住院总收入(结算日期)', 'metadata': {'code': 'S0010006', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010027', 'text': '住院药品总收入(结算日期)', 'metadata': {'code': 'S0010027', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010047', 'text': '住院材料总收入(结算日期)', 'metadata': {'code': 'S0010047', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010002', 'text': '全院总收入(结算日期)', 'metadata': {'code': 'S0010002', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010063', 'text': '全院医疗总收入(结算日期)', 'metadata': {'code': 'S0010063', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010028', 'text': '住院药品总收入(交账日期)', 'metadata': {'code': 'S0010028', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0150044', 'text': '住院医保总金额', 'metadata': {'code': 'S0150044', 'theme': '医保主题'}, 'distance': 0}, {'id': 'S0150048', 'text': '住院基金支付总金额', 'metadata': {'code': 'S0150048', 'theme': '医保主题'}, 'distance': 0}, {'id': 'S0010008', 'text': '住院总收入(核算日期)', 'metadata': {'code': 'S0010008', 'theme': '收入主题'}, 'distance': 0}, {'id': 'S0010029', 'text': '住院药品总收入(核算日期)', 'metadata': {'code': 'S0010029', 'theme': '收入主题'}, 'distance': 0}, {'id': 'C0000058', 'text': '住院医疗占比(结算日期)', 'metadata': {'code': 'C0000058', 'formula': '{S0010067/S0010005}'}, 'distance': 85.44193267822266}, {'id': 'C0000060', 'text': '住院医疗占比(核算日期)', 'metadata': {'code': 'C0000060', 'formula': '{S0010069/S0010007}'}, 'distance': 108.61600494384766}, {'id': 'C0000057', 'text': '住院医疗占比(计费日期)', 'metadata': {'code': 'C0000057', 'formula': '{S0010066/S0010004}'}, 'distance': 108.98963928222656}, {'id': 'C0000059', 'text': '住院医疗占比(交账日期)', 'metadata': {'code': 'C0000059', 'formula': '{S0010068/S0010006}'}, 'distance': 112.00505828857422}, {'id': 'C0000018', 'text': '住院药占比(结算日期)', 'metadata': {'code': 'C0000018', 'formula': '{S0010027/S0010005}'}, 'distance': 118.73735046386719}, {'id': 'C0000038', 'text': '住院耗材占比(结算日期)', 'metadata': {'code': 'C0000038', 'formula': '{S0010047/S0010005}'}, 'distance': 135.3946533203125}, {'id': 'C0000042', 'text': '全院医疗占比(结算日期)', 'metadata': {'code': 'C0000042', 'formula': '{S0010063/S0010002}'}, 'distance': 140.68531799316406}, {'id': 'C0000019', 'text': '住院药占比(交账日期)', 'metadata': {'code': 'C0000019', 'formula': '{S0010028/S0010006}'}, 'distance': 140.88381958007812}, {'id': 'C0000411', 'text': '住院医保基金支付占比', 'metadata': {'code': 'C0000411', 'formula': '{S0150048/S0150044}'}, 'distance': 141.25875854492188}, {'id': 'C0000020', 'text': '住院药占比(核算日期)', 'metadata': {'code': 'C0000020', 'formula': '{S0010029/S0010008}'}, 'distance': 144.33705139160156}], 'themes': ['医保主题', '收入主题']}\n"
     ]
    }
   ],
   "source": [
    "result = chroma.query_indicators(\"按结算统计住院医疗占比\",10, True)\n",
    "themes = result['themes']\n",
    "# result = chroma.format_indicators_table(result['indicators'])\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "| 指标代码 | 指标描述 | 关联主题 | 计算公式 |\n",
      "|---|---|---|---|\n",
      "| S0010067 | 住院医疗总收入(结算日期) | 收入主题 | - |\n",
      "| S0010005 | 住院总收入(计费日期) | 收入主题 | - |\n",
      "| S0010007 | 住院总收入(交账日期) | 收入主题 | - |\n",
      "| S0010069 | 住院医疗总收入(核算日期) | 收入主题 | - |\n",
      "| S0010066 | 住院医疗总收入(计费日期) | 收入主题 | - |\n",
      "| S0010004 | 全院总收入(核算日期) | 收入主题 | - |\n",
      "| S0010068 | 住院医疗总收入(交账日期) | 收入主题 | - |\n",
      "| S0010006 | 住院总收入(结算日期) | 收入主题 | - |\n",
      "| S0010027 | 住院药品总收入(结算日期) | 收入主题 | - |\n",
      "| S0010047 | 住院材料总收入(结算日期) | 收入主题 | - |\n",
      "| S0010002 | 全院总收入(结算日期) | 收入主题 | - |\n",
      "| S0010063 | 全院医疗总收入(结算日期) | 收入主题 | - |\n",
      "| S0010028 | 住院药品总收入(交账日期) | 收入主题 | - |\n",
      "| S0150044 | 住院医保总金额 | 医保主题 | - |\n",
      "| S0150048 | 住院基金支付总金额 | 医保主题 | - |\n",
      "| S0010008 | 住院总收入(核算日期) | 收入主题 | - |\n",
      "| S0010029 | 住院药品总收入(核算日期) | 收入主题 | - |\n",
      "| C0000058 | 住院医疗占比(结算日期) | - | {S0010067/S0010005} |\n",
      "| C0000060 | 住院医疗占比(核算日期) | - | {S0010069/S0010007} |\n",
      "| C0000057 | 住院医疗占比(计费日期) | - | {S0010066/S0010004} |\n",
      "| C0000059 | 住院医疗占比(交账日期) | - | {S0010068/S0010006} |\n",
      "| C0000018 | 住院药占比(结算日期) | - | {S0010027/S0010005} |\n",
      "| C0000038 | 住院耗材占比(结算日期) | - | {S0010047/S0010005} |\n",
      "| C0000042 | 全院医疗占比(结算日期) | - | {S0010063/S0010002} |\n",
      "| C0000019 | 住院药占比(交账日期) | - | {S0010028/S0010006} |\n",
      "| C0000411 | 住院医保基金支付占比 | - | {S0150048/S0150044} |\n",
      "| C0000020 | 住院药占比(核算日期) | - | {S0010029/S0010008} |\n",
      "\n"
     ]
    }
   ],
   "source": [
    "result = chroma.format_indicators_table(result['indicators'])\n",
    "print(result)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['医保主题', '收入主题']\n"
     ]
    }
   ],
   "source": [
    "print(themes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Add of existing embedding ID: ProDate_危急值处理主题\n",
      "Add of existing embedding ID: PHUnit_药房科室库存日报\n",
      "Add of existing embedding ID: AdmCode_住院证登记表\n",
      "Add of existing embedding ID: AdmDep_住院证登记表\n",
      "Add of existing embedding ID: SFFlag_住院证登记表\n",
      "Add of existing embedding ID: Receiver_建卡费主题\n",
      "Add of existing embedding ID: SFFlag_药库业务明细表\n",
      "Add of existing embedding ID: PHUnit_药库业务明细表\n",
      "Add of existing embedding ID: PHUnit_药库业务明细表\n",
      "Add of existing embedding ID: userDr_药库业务明细表\n",
      "Add of existing embedding ID: AdmNo_病理切片主题\n",
      "Add of existing embedding ID: AdmType_病理切片主题\n",
      "Add of existing embedding ID: PatSex_病理切片主题\n",
      "Add of existing embedding ID: Age_病理切片主题\n",
      "Add of existing embedding ID: ReqDate_病理切片主题\n",
      "Add of existing embedding ID: SFFlag_病理切片主题\n",
      "Add of existing embedding ID: StatisticDate_病理切片主题\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "| 维度代码 | 维度描述 | 所属主题 |\n",
      "|---|---|---|\n",
      "| AdmType | 就诊类型 | 收入主题 |\n",
      "| AdmType | 就诊类型 | 医保主题 |\n",
      "| OpCat | 门诊大类 | 收入主题 |\n",
      "| AdmNo | 就诊信息 | 收入主题 |\n",
      "| AdmNo | 就诊信息 | 医保主题 |\n",
      "| OpSubCat | 门诊子类 | 收入主题 |\n",
      "| RecDoc | 接收医生 | 收入主题 |\n",
      "| AdmStatus | 就诊身份类型 | 收入主题 |\n",
      "| AdmStatus | 就诊身份类型 | 医保主题 |\n",
      "| RecDocMG | 接收医生诊疗组 | 收入主题 |\n",
      "\n"
     ]
    }
   ],
   "source": [
    "result = chroma.get_dimensions_table(\"就诊量\",10, themes)\n",
    "print(result)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "langflow",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
